welcome back now in this tutorial we are going to learn how to create a Data Cube because Data Cube is the bricks we use in data warehouse the Data Cube will organize your data around the interest like we learned in pivot table the interest might be any business like the profit or the sales or the views or likes or the comments of songs and videos and then the dimensions of the data cube will be the things you can create a category and subcategory you can zoom in and zoom out in this tutorial we are going to look into the very specific creation and play with the data cube so let's first start with the setup, and this one we will need an external package for the setup of this data cube we are going to need to install atoti that will be the package we need for creating Data Cube and of course we can use our dataframe's pivot table but this package can give us some extra functionality and it is quite easy to use as well so you are going to have the !pip install with the name of the package atoti once you've done that you are going to again import pandas as pd and then you are going to import this package atoti as tt then you are going to load our data that is part of our session and you are first going to create a session because that is the major object in that package tt so once the session is created you are going to read the data in this time we are going to still use our Spotify YouTube sample I have already uploaded it into this place so again you can click the file and you can open the files and then you can download this CSV file in our lesson and post it here by dropping or by clicking this button to upload it once you have the data loaded in which is the data we have played many times and it just comes out of the head to make sure you successfully loaded the data then we can create a view and this view is actually creating the session.read_csv() so basically this is the thing similar to our data frame but we are actually directly read into the session of this package once we have the session read in rather than just read in the path of that session we are going to specify the keys so we just learned that these keys as artist track album they are actually corresponding to the index we used in the pivot table let's print out the view head and have a look in here we can see that because we have the artist and the track and album as our dimensions okay now let's try to create a data cube rather than just to have a view of it for the data cube as you can see we created the cube from session.create cube and then we fit in our loaded CSV and then we just fit in and give it a name and the cube as you can see here has 2 things the first one is dimensions the second one is measures dimensions basically will be automatically the possible categorical value as you can see here album album type artist licensed track official video so those are all the dimensions you can utilize in this sample set and for the measures the measures will be automatically aggregating about all kinds of possible ways like the comments we have mean sum and for the likes we have mean and sum for the stream for the view for contributors etc we all kind of try to aggregate them in a meaningful way as you can see here why I recommend this package to do the data cube is because pivot tablehave to create the measurements as value create the dimensions as index and you have to go back and change every time but for the cube they are always just automatically created for you and for all possible choices and we can get those measures out from cube that measures attribute and we can also get the levels out is because we want to know how the categories are hierarchically distributed let's play with the cube and you see how the cube can help us and we learned that in the cube basically we have certain terminology because the cube is based on dimensions depends on the number of dimension we may have 0 dimension that will be the aggregated 1 number result of everything in your dataset that will be called apex or 0D and if you have one particular dimension split out for example you just want to know the artist or you just want to know the album etc that will be the 1 dimension if you have all kinds of dimensions included that will be your base or you have all the possible dimensions in play to select those particular detailed information let's look at the apex if we just want to do a query and we just want to know the views and the SUM as you can see because it is APEX every single artist every single album will be aggregated into here so this views that sum is basically all the number for everything in your dataset and you can get that immediately setting the query to the cube and also you can set up the view sum and you have the level identified that will be your 1D because in the level lyou are selecting just 1 level item here as you can see here we specify the m which is the measurement we specify the m which is the measurement and here we specify the l which is the level so for this 1D you can see that you have artist and then views basically you are using this dimension to split this total number into separate numbers so you get more details of how each of the artist contributs to the aggregation Views.SUM and you can also specify something different such as album this is another 1D is because rather than you separated things by the artist now you are separating things by the album and then you can see that those albums are contributing a lot in comparison with this one for 2D again you need to specify more levels or more dimensions and if you have the 2D basically you are going to know not just the albumn ot just the artist but in a combination that which album belonged to which artists contribute to what amount of the views and the sum so again you are zoom in in this case because you explored from one value into multiple value in one dimension and now in more detailed value in 2 dimensions in this case and also you can do the slicing if you just want to know a particular artist like we did in the pivot table if you just want to know the Beatles then you can see how the sum of all the Beatles break it into the album and the track because we have the levels now as a 2D and these filters as artist equal to the Beatles can just help you to slicing the data cube into the way you like and we can also do the same thing for Michael Jackson we can see that these albums and these tracks are getting a lot of views like the Billie Jean and also we can select the filter as official video is true for the album and the track so we can eliminate all those non official videos or fan-made videos and only see those ones that are officially launched by the artist and then we can do another thing is that here those fan viewed fan made or unofficial video can also contribute to a lot of views in terms of the album and the track for the 3D now we can feed any three level of your choice into so that we can split further for example here for the view of SUM for this particular number it is actually specified by the album by the track and by the official video is true or false and then we can do this 3D slicing as well again for Machael Jackson we can go to that here this video is actually a non official video from the album from this track and we can see it has a lot of views as well so again like our pivot table the data cube with this package atoti is actually very powerful however it leads a lot of practice because in this package we definitely see some other pattern of calling the functions because we see that we have session and session read things in as a view and we are going to create the cube based on session and view and then we're going to give the m as measurement and l as the levels etc, in further queries and the queries will be having the m, l, and also filter in order to get the meaningful result howeverI have to admit that this package is really powerful if we want to play with data cube if you want to organize your data in a data warehouse way for a meaningful analysis so again I will leave you for playing with the package and with the data set have fun and I'll see you later